﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Yamfinder.Data.Tests
{
    [TestClass]
    public class UnixTimeExtensionMethodTests
    {
        [TestMethod]
        public void TestDateTimeUnixConversion()
        {
            long unixTimeValue = 342342;
            long unixTimeValueEpoch = 0;

            var dateTimeValue = unixTimeValue.DateTimeFromEpochTime();
            var dateTimeValueEpoch = unixTimeValueEpoch.DateTimeFromEpochTime();

            Assert.IsTrue(dateTimeValue == new DateTime(1970,1,4,23,5,42));
            Assert.IsTrue(dateTimeValueEpoch == new DateTime(1970, 1, 1, 0, 0, 0));
        }

        [TestMethod]
        public void TestDateTimeUnixConversionBackward()
        {
            var dateTime = new DateTime(2004, 8, 10, 12, 12, 12);

            var unixTimeValue = dateTime.ToUnixEpochTime();

            Assert.IsTrue(unixTimeValue == 1092139932);
        }
    }
}
